<template>
	<view class="wrap">
		<view class="content">
			<scroll-view class="scrool-more" style="height: 93%" scroll-y="true" scroll-with-animation="true">
			<u-form class="form" :model="model" ref="uForm" label-position="left">
				<view v-for="(item,index) in model.rateList" :key="index">
					<u-card :show-head="false">
						<view class="" slot="body">
							<view >
								<u-form-item label="反馈人:" prop="rateUserName" label-width="130">
									{{item.rateUserName}}
								</u-form-item>
								<u-form-item label="谈话内容是否属实:" prop="rateTalkIsRealName" label-width="130">
									{{item.rateTalkIsRealName}}
								</u-form-item>
								<u-form-item label="对本次谈话的建议:" prop="rateContent" label-width="130">
									{{item.rateContent==''?'无':item.rateContent}}
								</u-form-item>
								<u-form-item label="反馈内容:" prop="`rateList.${index}.feedback`" label-width="130" required>
									<u-input type="textarea" placeholder="请输入反馈内容" v-model="item.feedback" :border="true" height="200" maxlength="500" />
								</u-form-item>
							</view>
						</view>
					</u-card>
				</view>
			</u-form>
			</scroll-view>
			<view class="footer">
				<view style="display: flex;flex-direction: row; margin-left: 10rpx;margin-right: 10rpx;">
					<u-button class="btn" style="width: 50%;margin-right: 10rpx;" type="primary" @click="submit">提交</u-button>
					<u-button class="btn" style="width: 50%;" @click="cancel">取消</u-button>
				</view>
			</view>
			
		</view>
	</view>
</template>
 
<script>
	import {validatenull} from '@/common/validate.js'
	export default {
		data() {
			return {
				model: {
					rateList: []
				},
				rules: {
					feedback: [
						{
							required: true,
							message: '请填写反馈内容！',
							trigger: ['change','blur'],
						}
					],
				},
			};
		},
		mounted() {
			
		},
		onLoad(params){
			this.$u.api.mis.misAssistantTalk.listRateByTalkId({talkId: params.talkId}).then(res => {
				let list=[];
				res.data.forEach(item => {
				  if (item.rateType==='2') {
					list.push(item);
				  }
				});
				this.model.rateList=list;
			});
		},
		onReady() {
			
		},
		watch: {
			
		},
		methods: {
			submit() {
				let flag=false;
				this.model.rateList.forEach(item => {
				  if(validatenull(item.feedback)){
					  flag=true;
				  }
				});
				if (flag) {
					this.$u.toast('请填写反馈内容！');
					return ;
				} 
				this.$refs.uForm.validate(valid => {
					if (valid) {
						let flag=false;
						this.model.rateList.forEach(item => {
						  if(validatenull(item.feedback)){
							  flag=true;
						  }
						});
						if (flag) {
							this.$u.toast('请填写反馈内容！');
							return ;
						} 
						uni.showLoading({
							title: '提交中....'
						})
						this.$u.api.mis.misAssistantTalk.submitFeedBack(this.model.rateList).then(res => {
							uni.hideLoading();
							uni.showModal({
								title: '提示',
								content: res.msg,
								showCancel: false,
								success: function () {
									if (res.code == 200) {
										uni.navigateTo({url: 'index'});
									}
								}
							});
						});
					} else {
						this.$u.toast('请填写必填项。');
					}
				});
			},
			cancel() {
				uni.navigateTo({url: 'index'});
			},
			handleDateConfirm(e){
				this.model.talkTime=e.year+'-'+e.month+'-'+e.day+' '+e.hour+":"+e.minute+":"+e.second;
				this.talkTimeShow=false;
			},
			chooseStudent(){
				this.$refs.studentRef.setDefaultVal(this.model.userList);
				this.$refs.studentRef.open();
			},
			doSelected(){
				this.model.userList=this.$refs.studentRef.getData();
				let userId=[];
				if (this.model.userList.length > 0) {
					let list = [];
					this.model.userList.forEach(item => {
					  list.push(item.id);
					});
					this.model.talkUserId = list.join(",");
				} else {
					this.model.talkUserId = '';
				}
				this.$refs.studentRef.close();
			},
			handleClose(tag) {
			  this.model.userList.splice(this.model.userList.indexOf(tag), 1);
			},
			talkTypeChange(val) {
				if(val==='2'){
					this.popup.multiple=true;
				}else if(val==='1'){
					this.popup.multiple=false;
				}else{
					this.popup.multiple=false;
					this.model.userList=[];
				}
			}
		}
};
</script>
 
<style lang="scss" scoped>
.button {
    background-color: #fff;
    padding-top: 10px;
    position: absolute;
    width: 100%;
    bottom: 0;
    height: 55px;
}
 .content {
		background-color: #ffffff;
		bottom: 0px;
		left: 0;
		right: 0;
		overflow-y: auto;
		height: 100%;
		position: fixed;
		overflow-x: hidden;
		.scroll_view_style{
			height: 100%;
		}
   }
  .footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		margin-top: 10;
		z-index: 10;
  }
</style>